//
//  XZPageView.swift
//  高仿斗鱼直播
//
//  Created by 珍 on 17/4/21.
//  Copyright © 2017年 zhenzhen. All rights reserved.
//

import UIKit

class XZPageView: UIView {
    
    fileprivate var titles:[String]
    fileprivate var childVCs:[UIViewController]
    fileprivate var parentVC : UIViewController
    fileprivate var style: XZTItleViewStyle
    fileprivate var titleView : XZTitleView!

    init(frame: CGRect, titles:[String],childVCs:[UIViewController],parentVC:UIViewController,style: XZTItleViewStyle) {
        
        self.titles = titles
        self.childVCs  = childVCs
        self.parentVC = parentVC
        self.style = style
        super.init(frame:frame)
        
        
        setupUI()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
   

}

extension XZPageView{

    fileprivate func setupUI(){
    
        setupTitleView()
        setupContView()
    
    
    }
    private func setupTitleView(){
    
        let titleFrame = CGRect(x: 0, y: 0, width: bounds.width, height:style.titleViewHeight)
        titleView = XZTitleView(frame: titleFrame, titles:titles )
        titleView.backgroundColor = UIColor.brown
 
    }
    private func setupContView(){
    
    
        let contViewFrame = CGRect(x: 0, y: style.titleViewHeight, width: bounds.width, height: bounds.height - style.titleViewHeight)
    
        let contView = XZContentView(frame:contViewFrame, ChildVcs: childVCs, parentVC: parentVC)
        addSubview(contView)
        contView.backgroundColor = UIColor.randomColor()
         
    }


}
